#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin

start_sh() {
	echo Press ^D to continue booting
	/bin/sh
}

DEV_BOOT=md3

echo Configured boot device: /dev/${DEV_BOOT}

echo Mounting proc
mount proc /proc -t proc

echo Press any key within 5 seconds to enter shell
if read -n 1 -s -t 5; then start_sh; fi

echo Mounting new root
mount -o ro /dev/${DEV_BOOT} /root

echo Unmounting proc
umount /proc

echo Changing root
cd /root
pivot_root . initrd

echo Starting new init
exec chroot . /sbin/init -i <dev/console >dev/console 2>&1

umount /initrd

#blockdev --flushbufs /dev/ram0

